1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| #include <iostream> #include <opencv2/opencv.hpp>
using namespace std; using namespace cv;
int main() { Mat img,out_img,img_gray; img = imread("/home/v/home.png"); if (img.empty()){ cout << "Could not open or find the image" << endl; return -1; }
cvtColor(img, img_gray, COLOR_BGR2GRAY); imshow("img gray",img_gray);
out_img = img_gray.clone(); for (int i=0;i<img_gray.rows;i++){ for (int j=0;j<img_gray.cols;j++){ out_img.at<uchar>(i,j) = 6*pow((double)(img_gray.at<uchar>(i,j)),0.5); } }
normalize(out_img,out_img,0,255,NORM_MINMAX); convertScaleAbs(out_img,out_img); imshow("伽马变换",out_img); waitKey(0); return 0; }
|